﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Linq;
using System.Text; 
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Script.Services; 
using System.Web.Security;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Register : System.Web.UI.Page
{
    protected override void InitializeCulture()
    {
        if (Session["SELECTED_LANGUAGE"] != null)
        {
            string current_language = Session["SELECTED_LANGUAGE"].ToString();

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(current_language);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(current_language);
        }
        else
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture;
        }

        base.InitializeCulture();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        emailValidator.ErrorMessage = GetLocalResourceObject("ERROR_INCORRECT_EMAIL_FORMAT").ToString();
        passwordMatchValidator.ErrorMessage = GetLocalResourceObject("ERROR_PASSWORD_DOES_NOT_MATCH").ToString();
        loginValidator.ErrorMessage = GetLocalResourceObject("ERROR_LOGIN_ALREADY_EXIST").ToString();
        loginRequiredFieldValidator.ErrorMessage = GetLocalResourceObject("ERROR_REQUIRED_FIELD").ToString();
        passwordRequiredFieldValidator.ErrorMessage = GetLocalResourceObject("ERROR_REQUIRED_FIELD").ToString();
        confirmPasswordRequiredFieldValidator.ErrorMessage = GetLocalResourceObject("ERROR_REQUIRED_FIELD").ToString();
        emailRequiredFieldValidator.ErrorMessage = GetLocalResourceObject("ERROR_REQUIRED_FIELD").ToString();
    }
    protected void btnCreateAccount_Click(object sender, EventArgs e)
    {

        StringBuilder sb = new StringBuilder();

        cmpUser new_user = new cmpUser();

        new_user.Login = txtLogin.Text;
        new_user.First_name = txtFirstName.Text;
        new_user.Last_name = txtLastName.Text;
        new_user.password = txtPassword.Text;
        new_user.email = txtEmail.Text;
        new_user.phone = txtPhone.Text;
                
        /*
           if (TextBox4.Text == TextBox5.Text)
           {
               new_user.create_user();
           }

      //     MailSender send_mail = new MailSender();

   //        send_mail.SendActivationLink(new_user.email); 

           if (Membership.ValidateUser(TextBox3.Text, TextBox4.Text))
           {
               FormsAuthentication.RedirectFromLoginPage(TextBox3.Text, false);
           }*/
    }

    protected void Link_EN_Click(object sender, EventArgs e)
    {
        Session.Add("SELECTED_LANGUAGE", "en-US");
        Response.Redirect(Request.Url.AbsoluteUri);
    }
    protected void Link_RU_Click(object sender, EventArgs e)
    {
        Session.Add("SELECTED_LANGUAGE", "ru-RU");
        Response.Redirect(Request.Url.AbsoluteUri);
    }
}